extends Node2D

# 相机移动速度
@export var camera_speed: float = 200.0

# 相机引用
@onready var camera: Camera2D = $Camera2D

func _process(delta):
	var direction = Vector2.ZERO
	
	# 处理输入来移动相机
	if Input.is_action_pressed("ui_right"):
		direction.x += 1
	if Input.is_action_pressed("ui_left"):
		direction.x -= 1
	if Input.is_action_pressed("ui_down"):
		direction.y += 1
	if Input.is_action_pressed("ui_up"):
		direction.y -= 1
	
	# 归一化方向向量，避免对角线移动速度更快
	if direction.length() > 0:
		direction = direction.normalized()
	
	# 移动相机
	camera.position += direction * camera_speed * delta 